import java.util.Scanner;
public class  ookOrder {
    static Scanner sc =new Scanner(System.in);
    public static class Book{
        int id;
        String name;
        Double price;
        int storage;
    }
    public static class OrderItem {
        Book book= new Book();
        int num=0;
        Double pri;
        void input(){
            System.out.println("请输入图书编号选择图书(输入0停止购买)：");
            book.id =sc.nextInt();
            if (book.id == 0) {
                boolean shopping = false;
            }
            System.out.println("请输入购买图书数量(输入0停止购买)：");
            num =sc.nextInt();
            pri=book.price*num;
        }
    }
    public static class Order {
        Double total;
        void items() {
            System.out.println("     图书列表");
            System.out.println("图书编号  图书名称      图书单价    库存数量");
            System.out.println("----------------------------------------");
            System.out.println("1        Java教程      30.6      30   ");
            System.out.println("2        JSP教程       42.1      40   ");
            System.out.println("3        SSH架构       47.3      15   ");
            System.out.println("----------------------------------------");
        }

        public static void main(String[] args) {
            Book b1 = new Book();
            Book b2 = new Book();
            Book b3 = new Book();
            b1.id=1;
            b1.name = "Java教程";
            b1.price = 30.6;
            b1.storage = 30;
            b1.id = 2;
            b2.name = "JSP教程";
            b2.price = 42.1;
            b2.storage = 40;
            b3.id = 3;
            b3.name = "SSH架构";
            b3.price = 47.3;
            b3.storage = 15;
            Order order = new Order();
            OrderItem orderItem = new OrderItem();
            orderItem.book.id=1;
            order.items();
            boolean shopping=true;
            while (shopping)
            {
                orderItem.input();
                switch (orderItem.book.id) {
                    case 1:
                        orderItem.pri = orderItem.num * b1.price;
                        break;
                    case 2:
                        orderItem.pri = orderItem.num * b2.price;
                        break;
                    case 3:
                        orderItem.pri = orderItem.num * b3.price;
                        break;
                    default:
                        break;
                }
                System.out.println("请继续购买图书。");
                order.total += orderItem.pri;
            }
            System.out.println("      图书订单");
            System.out.println("图书订单号：00001");
            System.out.println("-----------------------");
            System.out.println("订单金额：      "+order.total);
        }
    }}
